<cfscript>    
    view = createObject("component", session.rootDir & ".views.layout");
    if( Session.Auth EQ True and (Session.strAuthType EQ Session.MANAGERS or Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) ){
		view.init("Step 4:  Finance Manager - Termination",
			"/jquery/ui-1.8.5/jquery-ui.min.js,/jquery/plugins/scrollTo/jquery.scrollTo-1.4.2-min.js, /" & session.rootDir & "/static/js/SCF/Step4-FinanceManagerTerm.js",
			"/jquery/ui-1.8.5/themes/cupertino/jquery-ui.css","Home",main, "Termination");
    }else{
        view.init("Denied","","","Home","Denied");
    }    
    view.html();
</cfscript>

<cffunction name="main" access="public" output="true" returntype="any">
    <cfparam default="-1" name="URL.TermReqID" />
    <cfscript>
        import models.*;
        FormAction = '/' & session.rootDir & '/controller/SubmitHandlerTermination.cfm?SCFStep4=update_finance_manager';
        FormCompleteAction = '/' & session.rootDir & '/termination/status.cfm'; //when submit is all done.
        KronosQueries = CreateObject("component", session.rootDir & ".DatabaseQueries.Kronos");     
        if( isDefined('URL.TermReqID') AND URL.TermReqID NEQ -1 ){
            StepActions = ORMExecuteQuery("FROM StepActions WHERE TermReqID = ? AND StepsID = 24", [URL.TermReqID] );
        }else{
            StepActions = ORMExecuteQuery("FROM StepActions WHERE StepsID = 24 AND ActTimeStamp IS NULL AND TermReqID IS NOT NULL");
            URL.TermReqID = -1;
        }
    </cfscript>
    
    
    <cfoutput> 
    <h1 class="title">Step 4:  Finance Manager - Termination</h1>
        <div class="entry">    
            Welcome, #Session.EmpInfo.FirstName# #Session.EmpInfo.LastName#.  
            In this step, we'll confirm that the terminated individuals 
            have indeed been terminated in the financial system.  
            This is the list of employees that are staged for 
            termination in Finance.  After successfully terminating the 
            employee, please place a check in the box next to their name 
            and hit the "Complete" button.  This will update their EPAR 
            record and remove them from the Finance queue. 
            <br /><br /> 

            <cfform name="frmStep4" method="post" action="#FormAction#">
                <table width=100%>
                    <tr> 
                        <td align="left"><strong>Employee Name</strong></td>
                        <td align="left"><strong>Cost Code</strong></td>
                        <td align="left"><strong>Termination Date</strong></td>
                    </tr>
    
                    <cfloop from="1" to="#ArrayLen(StepActions)#" index="i">
                        <cftry>
                        	<cfset TermRequest = entityLoadByPK("TerminationRequests", StepActions[i].getTermReqID()) />
	                        <cfset Employee = KronosQueries.funcGetAllEmployees(TermRequest.getRosettaID()) />
	                        
	                        <cfif Employee.RecordCount NEQ 0>
	                            <tbody id="#StepActions[i].getStepActionsID()#" class="EmployeeCostCode">
	                                <tr> 
	                                    <td nowrap="nowrap">#Employee.FirstName# #Employee.LastName#</td>
                                        <td >
                                           <cfinput type="text" name="CostCode" error_message="The badge number for '#Employee.FirstName# #Employee.LastName#' 
                                               is required and must be numeric.  Please provide the number on the back of their badge."/>
                                           <cfinput type="hidden" name="RosettaID" value="#Employee.RosettaID#" />
                                           <cfinput type="hidden" name="TermReqID" value="#TermRequest.getTerminationRequestsID()#" />
                                        </td>
	                                    <td>HR: #DateFormat(TermRequest.getSysTermDate(),'mm/dd/yy')#</td>	                                    
	                                </tr>
	                                <tr>
	                                    <td>&nbsp;</td> 
	                                </tr>
	                            </tbody>
	                        </cfif>                        
                        <cfcatch type="Any" >
                            
                        </cfcatch>
                        </cftry>

                    </cfloop>                
    
                    <tr>
                        <td colspan="4" align="right">
                            <cfinput type="hidden" name="FormAction" value="#FormAction#">
                            <cfinput type="hidden" name="FormCompleteAction" value="#FormCompleteAction#">
                            <cfinput type="button" name="Submit" value="Complete">
                        </td> 
                    </tr>
                </table>
                            
            </cfform>
        </div>    
    </cfoutput>
    
</cffunction>